﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using V5_Common;
using V5_BLL;
using V5_Model;

namespace V5_EShop.product
{
    public partial class recomment : BasicPage
    {
        protected int pid = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {

                pid = Input.SetInt(Request["lhpid"]);
                Action = Input.SetString(Request["laction"]);
                string s1 = Input.SetString(Request["txtpCommentContent"]);
                string s2 = Input.SetString(Request["txtpCommentEmail"]);
                string s3 = Input.SetString(Request["txtpCommentUserName"]);
                string s4 = Input.SetString(Request["ddlpmost"]);

                // if (Action == "savecomment")
                {
                    BLLProductComment bll = new BLLProductComment();
                    ModelProductComment model = new ModelProductComment();
                    int ID = bll.GetMaxId();
                    string CommentContent = s1;
                    string CommentName = s3;
                    string CommentEmail = s2;
                    string CommentIP = HTTPS.GetIP;
                    string ProductName = new BLLProduct().GetModel(pid, true).ProductName;
                    DateTime AddDateTime = DateTime.Now;
                    string ReplyComment = "";
                    string ReplyName = "";
                    int Pmost = Input.SetInt(s4);

                    model.ID = ID;
                    model.CommentContent = CommentContent;
                    model.CommentName = CommentName;
                    model.CommentEmail = CommentEmail;
                    model.CommentIP = CommentIP;
                    model.ProductName = ProductName;
                    model.ProductID = pid;
                    model.AddDateTime = AddDateTime;
                    model.ReplyComment = ReplyComment;
                    model.ReplyName = ReplyName;
                    model.Pmost = Pmost;

                    bll.Add(model);

                    Js.AlertAndRedirect("发布成功!", "/product-details-" + pid + ".aspx");
                }
            }
        }

        //添加留言
        private void Bind_AddComment(int pid)
        {
            //CommentContent 评论内容
            //CommentEmail 评论Email
            //CommentUserName 评论名称
            //pmost 评论等级

        }
    }
}
